//
//  HomePageListItemCell.swift
//  maopu
//
//  Created by 黄海波 on 2017/4/24.
//  Copyright © 2017年 maopu. All rights reserved.
//

import UIKit

class HomePageListItemCell: UITableViewCell {
    @IBOutlet var headerImg:UIButton!
    @IBOutlet var userNameLab:UILabel!
    @IBOutlet var posterBtn:UIButton! //楼主
    @IBOutlet var rankBtn:UIButton! //等级
    @IBOutlet var rankBtn_minX:NSLayoutConstraint!
    @IBOutlet var sexImg:UIImageView!  //性别
    @IBOutlet var timeLab:UILabel!  //时间
    @IBOutlet var contentLB:UILabel!
    @IBOutlet var titleLab:UILabel!
    @IBOutlet var tagBtn:UIButton!
    @IBOutlet var focusBtn:UIButton!  //关注数量
    @IBOutlet var commentBtn:UIButton! //评论数量
    
    @IBOutlet var titleLab_left:NSLayoutConstraint!
    
    @IBOutlet var collectionView:UICollectionView!
    @IBOutlet var collectionView_height:NSLayoutConstraint!
    
    fileprivate var lineView:UIView!

    override func awakeFromNib() {
        super.awakeFromNib()
        
        self.titleLab.font = UIFont.LightDefaultFont(18)
        self.titleLab.textColor = UIColor.m_textDeepColor()
        self.titleLab.lineBreakMode = .byCharWrapping
        self.titleLab.numberOfLines = 2
        self.titleLab.text = "说走就走的旅行"
        
        self.contentLB.font = UIFont.LightDefaultFont(14)
        self.contentLB.textColor = UIColor.m_home_textLightColor()
        self.contentLB.lineBreakMode = .byCharWrapping
        self.contentLB.numberOfLines = 2
        self.contentLB.text = "跨越自己狠简单特别简单的一件事情只要想去做的话"
        
        self.userNameLab.font = UIFont.LightDefaultFont(14)
        self.userNameLab.textColor = UIColor.m_textDeepColor()
        self.userNameLab.text = "皮皮虾"
        
        self.posterBtn.layer.masksToBounds = true
        self.posterBtn.layer.cornerRadius = 8
        self.posterBtn.isEnabled = false
        self.posterBtn.setTitle("楼主", for: UIControlState())
        self.posterBtn.backgroundColor = UIColor.m_landlordBgColor()
        self.posterBtn.setTitleColor(UIColor.m_landlordTextColor(), for: UIControlState())
        self.posterBtn.titleLabel?.font = UIFont.LightDefaultFont(10)
        
        self.rankBtn.layer.masksToBounds = true
        self.rankBtn.layer.cornerRadius = 8
        self.rankBtn.isEnabled = false
        self.rankBtn.backgroundColor = UIColor.m_rankBgColor()
        self.rankBtn.setTitle("  神经猫  ", for: UIControlState())
        self.rankBtn.setTitleColor(UIColor.m_rankTextColor(), for: UIControlState())
        self.rankBtn.titleLabel?.font = UIFont.LightDefaultFont(10)
        
        self.headerImg.setTitle("", for: UIControlState())
        self.headerImg.setImage(UIImage.init(named: "test_header"), for: UIControlState())
        self.headerImg.layer.masksToBounds = true
        self.headerImg.layer.cornerRadius = 15
        
        self.timeLab.font = UIFont.LightDefaultFont(11)
        self.timeLab.textColor = UIColor.RGB(r: 136, g: 136, b: 136)
        self.timeLab.text = "今天 15: 00"
        
        self.collectionView.backgroundColor = UIColor.blue
        
        self.tagBtn.backgroundColor = UIColor.m_tagBgColor()
        
        self.sexImg.image = UIImage.init(named: "sex_boy")
        
        lineView = UIView()
        lineView.backgroundColor = UIColor.m_lineColor()
        self.contentView.addSubview(lineView)
        self.lineView.snp.makeConstraints { (make) in
            make.left.right.bottom.equalTo(self)
            make.height.equalTo(1)
        }
        
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
    }
    
    func refreshCellData(cellType:Int = 0){
        if cellType == 0{
            self.titleLab_left.constant = 60
            self.posterBtn.isHidden = true
            self.posterBtn.setTitle("", for: UIControlState())
            self.rankBtn_minX.constant = -32
            self.focusBtn.isHidden = false
            self.commentBtn.isHidden = false
            
            self.focusBtn.set(image: UIImage.init(named: "focus_ico"), title: "89", titlePosition: .right, additionalSpacing: 5, state: UIControlState.normal)
            self.commentBtn.set(image: UIImage.init(named: "tool_comment"), title: "98", titlePosition: .right, additionalSpacing: 5, state: UIControlState.normal)
        }else{
            self.titleLab_left.constant = 20
            self.posterBtn.isHidden = false
            self.posterBtn.setTitle("楼主", for: UIControlState())
            self.rankBtn_minX.constant = 5
            self.focusBtn.isHidden = true
            self.commentBtn.isHidden = true
        }
    }
    
    
    
}
